/*
 * VeinsAdapter.h
 *
 *  Created on: Apr 26, 2014
 *      Author: shazbox
 */

#ifndef VEINSADAPTER_H_
#define VEINSADAPTER_H_
#include <stdio.h>
#include <iostream>
#include "BaseWaveApplLayer.h"
#include <jni.h>
#include <string.h>
#include <stdlib.h>
#include "JavaVehApp.h"
//#include "jveins_VeinsAdapter.h"

class JavaVehApp;

class VeinsAdapter {
public:
    virtual ~VeinsAdapter();
    static VeinsAdapter* getInstance();
    static void JNICALL messageToC (JNIEnv *, jobject,jint, jstring);
    static void JNICALL scheduleSelfMsg (JNIEnv *, jobject,jint, jstring);
    int registerEntity(std::string clazz, JavaVehApp * object);

    void sendBeacon(int id, std::string msg);
    void sendData(int id, std::string msg);
    void sendSelfMsg(int id, short kind);
    std::map<int,JavaVehApp*> map;

private:
    VeinsAdapter();
    static bool isCreated;
    static const char * adapterClass;
    static VeinsAdapter *instance;
    static int curID;
    JavaVMOption options[1];
    JNIEnv *env;
    JavaVM *jvm;
    JavaVMInitArgs vm_args;
    long status;
    jobject jAdapter;
};

#endif /* VEINSADAPTER_H_ */
